from apscheduler.schedulers.background import BackgroundScheduler
from django_apscheduler.jobstores import DjangoJobStore

scheduler = BackgroundScheduler()
scheduler.add_jobstore(DjangoJobStore(), 'default')


def startScheduler():
    scheduler.start()


def getAllJobs():
    return scheduler.get_jobs()


def removeJobByName(name):
    try:
        for item in scheduler.get_jobs():
            if item.id.find(name) != -1:
                scheduler.remove_job(item.id)
    except Exception as e:
        print(str(e))
        pass
